<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.01.
   查找公司控制器($$)*/

!defined('Q_PATH') && exit;

class Company_C_Controller extends InitController{

	public function index(){
		$nSiteId=intval(Q::G('site_id','G'));

		// 查询商家
		if(Q::G('jiajucompany_fullname')){
			$arrWhere=array();
			$arrWhere['jiajucompany_status']=1;
			$arrWhere['jiajucompany_fullname']=array('like','%'.Q::G('jiajucompany_fullname').'%');
			if($nSiteId){
				$arrWhere['site_id']=$nSiteId;
			}

			$sPageurl='';
			if(Q::G('site_id')){
				$sPageurl[]='site_id='.Q::G('site_id');
			}
			$sPageurl[]='id='.Q::G('id');
			$sPageurl[]='func='.Q::G('func');
			$sPageurl[]='jiajucompany_fullname='.Q::G('jiajucompany_fullname');
			if($sPageurl){
				$sPageurl='&'.implode('&',$sPageurl);
			}

			$nTotal=Model::F_('jiajucompany')->where($arrWhere)->getCounts();
			$oPage=Page::RUN($nTotal,8,'@www~@home://misc/company?page={page}'.$sPageurl);
			$arrCompanys=Model::F_('jiajucompany')
				->setColumns('jiajucompany_fullname,jiajucompany_shortname,jiajucompany_id,jiajucompany_status,jiajucompany_isavip,jiajucompany_isfvip')
				->where($arrWhere)
				->order('jiajucompany_id DESC')
				->limit($oPage->S(),$oPage->N())
				->getAll();
			
			$this->assign('arrCompanys',$arrCompanys);
			$this->assign('sPageNavbar',$oPage->P(array('id'=>'pagination','style'=>'li','current'=>'active')));
		}

		$this->display();
	}

}
